/* DataReceive.java 
* Created on Dec 13, 2012 
*@Author: Mr.Viet 
*@Phone: 01683430426 
*@Email: phamvanvietcdhd@gmail.com
*/ 
package com.session8; 

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.SocketException;

public class DataReceive {

	public DataReceive() {
	}

	public static void main(String[] args) {
		try {
			DatagramSocket socket = new DatagramSocket(2012);
			byte[] b = new byte[256];
			DatagramPacket pack = new DatagramPacket(b, b.length);
			socket.receive(pack);
			System.out.println("Data Receive");
			String d = new String(pack.getData());
			System.out.println(d);
		} catch (SocketException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}
